<%@page import="dao.ContatoDAO"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  
   
   <jsp:useBean id="dao" class="dao.ContatoDAO"/>
   <jsp:useBean id="contato" class="model.Cadastro"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<a href="home.html">Home</a>
<a href="adicionaContato.jsp">Adicoinar</a>
<form action="BuscaContato.do" method="post" >
 <table border="1">
  <tr>
            <th><input type="text" name="nome"/></th>
			<th>  <input type="submit" value="Buscar"/></th>
  </tr>
  <tr>

            <th><input type="radio" name="opcao" value="nome"> Nome<br></th>
			<th> <input type="radio" name="opcao" value="sobrenome"> Sobrenome</th>
			<th> <input type="radio" name="opcao" value="id"> ID</th>
  </tr>
 
 </table>
</form>
	<table border="1">
		<tr>
			<th>ID</th>
			<th>Nome</th>
			<th>Sobrenome</th>
			<th>Telefone</th>
			<th>Celular</th>
			<th>Email</th>
			<th>Cep</th>
			<th>rua</th>
			<th>Numero</th>
			<th>Bairro</th>
			<th>Complemento</th>
			<th>Editar</th>
			<th>Excluir</th>
		  
		</tr>
	
	<c:forEach var="contato" items="${dao.listaTodos}">
		<tr>
			<td>${contato.idCadastro}</td>
			<td>${contato.nome}</td>
			<td>${contato.sobrenome}</td>
			<td>${contato.telefone}</td>
			<td>${contato.celular}</td>
			<td>${contato.email}</td>
			<td>${contato.cep}</td>
			<td>${contato.rua}</td>
			<td>${contato.numero}</td>
			<td>${contato.bairro}</td>
			<td>${contato.complemento}</td>
			
			<td>
			<form action="EditaAction.do" method="post" >
			
			<input type="hidden" name="id" value="${contato.idCadastro}" />
			<input type="submit" value="Alterar"/>
			</form>
			
				</td>
			<td>
			<form action="DeleteContato.do" method="post" >
			
			   <input type="hidden" name="id" value="${contato.idCadastro}" />
			   <input type="submit" value="Excluir"/>
			</form>
			
			</td>
			
		</tr>
	 </c:forEach>	
	</table>
    
   
    

</body>
</html>